package com.xust.common.pagination.domain;

public class Page {
	
	//Input
    private int total;    //总记录数  
    private int page;    //当前页  
    private int rows = 10; //每页显示记录数  
    
    //Output
    private int totalPage;      //总页数  
    private int index;  //当前记录起始索引  

    public Page(){
    	
    }
    
    public Page(int page, int rows, int total){
    	this.total = total;
    	this.page = page;
    	this.rows = rows;
    }
    
    public int getTotalPage() {  
        return (int)Math.ceil(total/rows);  
    } 
    
    public int getTotal() {  
        return total;  
    }
    
    public void setTotal(int total) {  
        this.total = total;  
    }
    
    public int getPage() {  
        if(page<=0)  
            page = 1;  
        if(page > totalPage)  
            page = totalPage;  
        return page;  
    }
    
    public void setPage(int page) {  
        this.page = page;  
    }
    
    public int getRows() {  
        return rows;  
    }  
    public void setRows(int rows) {  
        this.rows = rows;  
    }  
    public int getIndex() {  
        index = (getPage() - 1) * getRows() + 1;  
        if(index<0) {
            index = 0;
        }
        return index;  
    }  
    public void setIndex(int index) {  
        this.index = index;  
    }  
}